package org.boot.ssm.wxshop.service.impl;

import org.boot.ssm.wxshop.common.impl.BaseServiceImpl;
import org.boot.ssm.wxshop.domain.News;
import org.boot.ssm.wxshop.mapper.NewsMapper;
import org.boot.ssm.wxshop.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: wxshop
 * @description: 新闻服务层实现
 * @author: Parasomnia
 * @create: 2018-03-16 14:08
 **/
@Service
public class NewsServiceImpl extends BaseServiceImpl<News> implements NewsService {
    @Autowired
    private NewsMapper newsMapper;

    @Override
    @Transactional
    public void updateDeleteMany(List<Integer> ids) {
        for (int a = 0;a<ids.size();a++){
            News news = new News();
            news.setIsDelete(0);
            news.setId(ids.get(a));
            updateDelete(news);
        }
    }

    @Override
    public void addOrEdit(News news) {
        if(news.getId()==null){//添加
            saveNoNull(news);
        }else{//修改
            updateNoNull(news);
        }
    }
}
